package com.moonshineproject.plugin.project.vo
{
	import flash.filesystem.File;
	
	public class FileWrapper
	{
		protected var _file:File;
		
		public function FileWrapper(file:File)
		{
			_file = file;
			if (file && file.isDirectory) updateChildren();
		}

		public function get file():File
		{
			return _file;
		}
		public function set file(v:File):void
		{
			_file = v;
			if (file && file.isDirectory) updateChildren();
		}

		public function get name():String
		{
			return file.name;
		}
		
		public function set name(v:String):void
		{
			//TODO: Implement this
		}

		private var _children:Array;
		public function get children():Array
		{
			if (!_children) updateChildren();

			return _children;
		}
		
		public function get nativePath():String
		{
			return file.nativePath;
		}
		
		public function updateChildren():void
		{
			if (!file.isDirectory) return;
			
			var c:Array = file.getDirectoryListing();
			_children = [];
			var f:File;
			for (var i:int = 0; i < c.length; i++)
			{
				f = c[i];
				if (!f.isHidden)
				{
					_children.push(new FileWrapper(f));
				}	
			}
		}

	}
}